//
//  StepCountDataModel.swift
//  TimeBoat
//
//  Created by Jun on 2022/9/8.
//  Copyright © 2022 Time Boat. All rights reserved.
//

import Foundation


/// 步数
@objcMembers class StepCountDataModel: NSObject {
    /// 步数, 4 byte
    var step: UInt32 = 0

    /// 距离, 4 byte
    var distance: UInt32 = 0

    /// 卡路里, 4 byte
    var calorie: UInt32 = 0
    
    
    private let DATA_LEN: Int = 12
    
    convenience init(buf: [UInt8]) {
        self.init()
        
        if (buf.count >= DATA_LEN) {
            var index = 0

            step = UInt32.toUInt32(buf: buf, offset: index)
            index += 4

            distance = UInt32.toUInt32(buf: buf, offset: index)
            index += 4

            calorie = UInt32.toUInt32(buf: buf, offset: index)
        }
    }
    
    @objc func toString() -> String {
        var str = self.yy_modelToJSONString()
        if nil == str {
            str = ""
        }
        
        return str!
    }
}
